﻿using System;
using System.Windows.Media;

namespace RoadSystemTest
{
    public enum Sites { Horizontal, Vertical };
    public enum LaneTypes { Forward, Backward };

    public class Point
    {
        public double X { get; set; }
        public double Y { get; set; }
        public Point()
        {
            X = 0;
            Y = 0;
        }
        public Point(double x, double y)
        {
            X = x;
            Y = y;
        }
        public Point(RoadSystemTest.Point p)
        {
            X = p.X;
            Y = p.Y;
        }
        public Point(System.Windows.Point p)
        {
            X = p.X;
            Y = p.Y;
        }
        public void FromPoint(Point other)
        {
            X = other.X;
            Y = other.Y;
        }
        public double Distance(Point other)
        {
            double xDiff = this.X - other.X;
            double yDiff = this.Y - other.Y;
            return Math.Sqrt(xDiff * xDiff + yDiff * yDiff);
        }
        public override string ToString()
        {
            return "(" + X.ToString() + "," + Y.ToString() + ")";
        }
        public void Translate(double x, double y)
        {
            X += x;
            Y += y;
        }
        public void Translate(Point other)
        {
            X += other.X;
            Y += other.Y;
        }
        public void ApplyToTranslateTransform(TranslateTransform tr)
        {
            tr.X = this.X;
            tr.Y = this.Y;
        }
        public void ApplyRotationTransform(RotateTransform tr)
        {
            System.Windows.Point p = tr.Transform(this.ToSystem());
            X = p.X;
            Y = p.Y;
        }
        public System.Windows.Point ToSystem()
        {
            return new System.Windows.Point(X, Y);
        }
    }

    public class TrafficEventArgs : EventArgs
    {
        public ICarObject car;
        public ILaneObject lane;
        public Point laneStart;
        public Point laneEnd;
        public ITrafficObject trafficObject;
    }

    public delegate void TrafficEventHandler(object sender, TrafficEventArgs e);
}